/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.camachosanchez.bean;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Zully
 */
@Entity
@Table(name = "ejes")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Ejes.findAll", query = "SELECT e FROM Ejes e"),
    @NamedQuery(name = "Ejes.findById", query = "SELECT e FROM Ejes e WHERE e.id = :id"),
    @NamedQuery(name = "Ejes.findByNumNeumaticos", query = "SELECT e FROM Ejes e WHERE e.numNeumaticos = :numNeumaticos"),
    @NamedQuery(name = "Ejes.findByPosicion", query = "SELECT e FROM Ejes e WHERE e.posicion = :posicion")})
public class Ejes implements Serializable, Comparable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "num_neumaticos")
    private Integer numNeumaticos;
    @Basic(optional = false)
    @Column(name = "posicion")
    private int posicion;
    @JoinColumn(name = "id_eje", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private TiposEje idEje;
    @JoinColumn(name = "id_funcion", referencedColumnName = "id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private FuncionEje idFuncion;

    public Ejes() {
    }

    public Ejes(Integer id) {
        this.id = id;
    }

    public Ejes(Integer id, int posicion) {
        this.id = id;
        this.posicion = posicion;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getNumNeumaticos() {
        return numNeumaticos;
    }

    public void setNumNeumaticos(Integer numNeumaticos) {
        this.numNeumaticos = numNeumaticos;
    }

    public int getPosicion() {
        return posicion;
    }

    public void setPosicion(int posicion) {
        this.posicion = posicion;
    }

    public TiposEje getIdEje() {
        return idEje;
    }

    public void setIdEje(TiposEje idEje) {
        this.idEje = idEje;
    }

    public FuncionEje getIdFuncion() {
        return idFuncion;
    }

    public void setIdFuncion(FuncionEje idFuncion) {
        this.idFuncion = idFuncion;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Ejes)) {
            return false;
        }
        Ejes other = (Ejes) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.camachosanchez.bean.Ejes[ id=" + id + " ]";
    }
    
    @Override
    public int compareTo(Object o) {
        Ejes eje = (Ejes) o;
        String posicion1 = "" + this.posicion;
        String posicion2 = "" + eje.posicion;
        return posicion1.compareTo(posicion2);

    }
}
